﻿@using Pyramid.Models
@using Pyramid.Mvc.Html
@model IEnumerable<StaffAchievementViewModel>
@{
	var qm = (StaffMonthlyQueryModel) ViewBag.QueryModel;
	var date = DateTime.Now.AddMonths(-1);
	var master = (StaffAchievementGatherMaster) ViewBag.Master;
	var status = master == null ? "未统计" : (master.StatusEnum == FinanceStatus.UnSettled ? "已统计" : "已结算");
}
<div class="pageHeader">
	@using (Html.BeginForm("List", "Achievement", FormMethod.Post, new {onsubmit = "return navTabSearch(this);", id = "pagerForm"}))
	{
		<div class="searchBar">
			<table class="searchContent">
				<tr>
					<td>年份：</td>
					<td>@Html.DropDownListForRange("year", 2010, date.Year, qm.Year)</td>
					<td>月份：</td>
					<td>@Html.DropDownListForRange("month", 1, 12, qm.Month)</td>
					<td>查询关键字：<input type="text" name="keywords" rel="pagerForm" value="@qm.Keywords" /></td>
					<td>
						<div class="buttonActive">
							<div class="buttonContent">
								<button type="submit">查询</button>
							</div>
						</div>
					</td>
				</tr>
			</table>
		</div>
	}
</div>
<div class="pageContent">
	<div class="pageContentBar">
		<div class="title">@(string.Format("{0}年{1}月份业绩统计", qm.Year, qm.Month))</div>
		<div>
			当前状态：@status
		</div>
		<div class="toolbar">
			@if (master == null || master.StatusEnum == FinanceStatus.UnSettled)
			{
				using (Html.BeginForm("Gather", "Achievement", FormMethod.Post, new {onsubmit = "return validateCallback(this, navTabAjaxDone);", id = "gatherForm"}))
				{
					<div>
						@Html.Hidden("year", qm.Year)
						@Html.Hidden("month", qm.Month)
					</div>
					<div class="buttonActive">
						<div class="buttonContent">
							<button type="submit">&nbsp;&nbsp;@(master != null ? "重新统计" : "立即统计")&nbsp;&nbsp;</button>
						</div>
					</div>
				}
			}
			@if (master != null && master.StatusEnum == FinanceStatus.UnSettled)
			{
				using (Html.BeginForm("Settle", "Achievement", FormMethod.Post, new {onsubmit = "return validateCallback(this, navTabAjaxDone);", id = "settleForm"}))
				{
					<div>
						@Html.Hidden("id", master.Id)
					</div>
					<div class="buttonActive">
						<div class="buttonContent">
							<button type="submit">&nbsp;&nbsp;结算&nbsp;&nbsp;</button>
						</div>
					</div>
				}
			}
		</div>
	</div>
	<table class="table" width="100%" layouth="110">
		<thead>
			<tr>
				<th width="100">@Html.DisplayNameFor(m => m.StaffCode)</th>
				<th width="120">@Html.DisplayNameFor(m => m.FullName)</th>
				<th width="80">@Html.DisplayNameFor(m => m.Gender)</th>
				<th width="150">@Html.DisplayNameFor(m => m.DepartmentName)</th>
				<th width="150">@Html.DisplayNameFor(m => m.Position)</th>
				<th width="150">@Html.DisplayNameFor(m => m.UserId)</th>
				<th>@Html.DisplayNameFor(m => m.TotalAmount)</th>
				<th></th>
			</tr>
		</thead>
		<tbody>
			@foreach (var s in Model)
			{
				<tr>
					<td>@s.StaffCode</td>
					<td>@s.FullName</td>
					<td>@s.GenderString</td>
					<td>@s.DepartmentName</td>
					<td>@s.Position</td>
					<td>@s.UserId</td>
					<td>@s.TotalAmount.ToString("C")</td>
					<td><a class="edit" href="@Url.Action("Details", new {userId = s.UserId, year = qm.Year, month = qm.Month})" target="dialog" mask="true" title="查看员工业绩明细" width="810" height="480" resizable="false"><span>查看明细</span></a></td>
				</tr>
			}
		</tbody>
	</table>
</div>
